package com.example.administrator.shihuo.myView;

import android.content.Context;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.administrator.shihuo.R;

/**
 * Created by Administrator on 16-3-21.
 */
public class TopBar extends LinearLayout implements View.OnClickListener {
    private static final String TAG = TopBar.class.getSimpleName();
    private Context context;
    private TextView tv;
    private ImageView topbar_back;
    private ImageView queren;
    private Handler handler;
    private String string = "http://www.1000phone.net:8088/qfxl/index.php?s=appapi&a=addremind";

    public TopBar(Context context) {
        this(context, null);
    }

    public TopBar(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TopBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.topbar, this, true);
        tv = ((TextView) findViewById(R.id.tttopbar));
        topbar_back = ((ImageView) findViewById(R.id.topbar_back));
        queren = ((ImageView) findViewById(R.id.queren));
        topbar_back.setVisibility(INVISIBLE);
        queren.setVisibility(INVISIBLE);
        tv.setVisibility(INVISIBLE);

    }

    public void setTitle(String content) {
        tv.setVisibility(VISIBLE);
        tv.setText(content);
    }

    public void setBack() {
        topbar_back.setVisibility(VISIBLE);
        topbar_back.setOnClickListener(this);
    }

    public void setYes() {
        queren.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.topbar_back:
                ((AppCompatActivity) context).finish();
//                ((AppCompatActivity) context).startActivity(new Intent(context, LoginActivity.class));
                break;
            case R.id.queren:
                //设定弹窗按钮

                break;
        }

    }

}
